<c:if test="${sessionBean.ejbSession.owner==null}" >
    <jsp:forward page="../login.jsp" />
</c:if>
<c:if test="${sessionBean.ejbSession.resume==null}" >
    <jsp:forward page="../user/homeUser.jsp" />
</c:if>
<script language="JavaScript">
function contar() {
  n = document.getElementById("editPostingForm:description").value.length;
  if (n > 20000) {
    document.getElementById("editPostingForm:description").value = document.getElementById("editPostingForm:description").value.substring(0, 20000);
  }
  else {
    document.getElementById("editPostingForm:contador").value = 20000-n;
  }
}
</script>
<f:view>
    <h:outputText value="Edit Resume Posting in #{resumeBean.resume.site.site}" style="font-size: 20px; font-weight: bold;"/>
    <h:form id="editPostingForm">
    <h:panelGrid>
    <rich:panel>
        <h:messages globalOnly="true" style="color: red" styleClass="errorMessage"/>
        <h:panelGrid columns="3">
            <h:outputText value="(*) Title:"/>
            <h:inputText id="title" maxlength="100" value="#{resumeBean.resume.title}" size="70" required="true" requiredMessage="This is a required field"/>
            <h:message for="title" style="color: red" styleClass="errorMessage"/>
            
            <c:if test="${!empty resumeBean.resume.site.areas}">
            <h:outputText value="Area:" />
            <a4j:region>
            <h:selectOneMenu id="area" value="#{resumeBean.areaId}" >
                <c:forEach var="area" items="#{resumeBean.resume.site.areas}" >
                    <f:selectItem
                        itemValue="#{area.id}"
                        itemLabel="#{area.area}"/>
                </c:forEach>
                <a4j:support event="onchange" reRender="locationPanel" ajaxSingle="true"/>
            </h:selectOneMenu>
            <a4j:status>
                <f:facet name="start">
                    <h:graphicImage  value="/images/ajax_process.gif"/>
                </f:facet>
            </a4j:status>
            </a4j:region>
            <h:message for="area" />
            </c:if>
    
            <h:outputText value="Specific Location:"/>
            <h:panelGroup id="locationPanel">
            <h:inputText id="location" maxlength="70" value="#{resumeBean.resume.location}" size="50" rendered="#{empty resumeBean.locationsResumeArea}"/>
            <h:selectOneMenu id="location1" value="#{resumeBean.resume.location}" rendered="#{!empty resumeBean.locationsResumeArea}">
                <c:forEach var="location" items="#{resumeBean.locationsResumeArea}" >
                    <f:selectItem
                        itemValue="#{location.location}"
                        itemLabel="#{location.location}"/>
                </c:forEach>
            </h:selectOneMenu>
            </h:panelGroup>
            <a4j:commandButton id="refreshLocationPanel" style="display: none; visibility: hidden;" reRender="locationPanel" ajaxSingle="true"/>
            
            <h:outputText value="(*) Description:"/>
            <h:inputTextarea id="description" onkeydown="contar()" onkeyup="contar()" value="#{resumeBean.resume.description}" rows="7" cols="80" required="true" requiredMessage="This is a required field"/>
            <h:panelGroup><h:inputText id="contador" onkeydown="contar()" onkeyup="contar()" value="#{resumeBean.contador}" size="5" /><h:message for="description" style="color: red" styleClass="errorMessage"/></h:panelGroup>
            
            <h:outputText value="(*) Email Address:"/>
            <h:inputText id="email" value="#{resumeBean.resume.email}" size="30" readonly="true" />
            <h:message for="email" style="color: red" styleClass="errorMessage"/>
        </h:panelGrid>
        
        <h:panelGrid columns="2">
            <h:outputText value="Reply To:"/>
            <h:selectOneRadio id="typeReplayTo" value="#{resumeBean.resume.typeReplyTo}" layout="pageDirection">
                <f:selectItem 
                    itemValue="real email"
                    itemLabel="use this email address for replies."/>
                <f:selectItem
                    itemValue="masked email"
                    itemLabel="reply to: resume-#{resumeBean.resume.code}@eez2find.com (eez2find.com anonymizes your real address and relays replies to it)."/>
                <f:selectItem 
                    itemValue="any email"
                    itemLabel=" DO NOT SHOW any email address (make sure to put a phone # or other contact info in your posting)."/>
            </h:selectOneRadio>
            
            <h:outputText value="Permissions:"/>
            <h:panelGrid columns="2">
                <h:selectBooleanCheckbox value="#{resumeBean.resume.directContact}" /><h:outputText value="OK for direct contact by recruiters."/>
                <h:selectBooleanCheckbox value="#{resumeBean.resume.othersContact}" /><h:outputText value="OK to contact you for other kind of services (commercial, offers, services, etc)."/>
            </h:panelGrid>
        </h:panelGrid>
        <h:panelGrid columns="2" >
            <h:commandButton id="submit" type="submit" value="Update" action="#{resumeBean.update}" onclick="if(!confirm('Your Post has been edited. Are you sure?'))return false" />
            <h:commandLink value="Preview" action="previewUpdate" />
        </h:panelGrid>
    </rich:panel>
    </h:panelGrid>
    </h:form>
    <h:form>
        <h:commandLink value="Back" action="#{resumeBean.backEdit}" >
            <f:setPropertyActionListener target="#{sessionBean.ejbSession.resume}" value="#{null}"/>
        </h:commandLink>
    </h:form>
    <rich:separator height="1" />
</f:view>
<script>document.getElementById("editPostingForm:refreshLocationPanel").click();</script>